
<template>
  <div class="query">
    <div class="check">
      <div class="c_right">
        <el-form id="my-profile" name="paraForm2" method="post" target="reportFrame2">
          <el-form-item style="display: none" name="hospital_code">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">医院编码</span>
                <el-input v-model="hospital_code" name="hospital_code" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <el-form-item style="display: none" name="medical">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">医疗机构</span>
                <el-input v-model="medical" name="medical" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <el-form-item style="display: none" name="lister">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">制表人</span>
                <el-input v-model="lister" name="lister" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <el-form-item style="display: none" name="tabTime">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">制表时间</span>
                <el-input v-model="tabTime" name="tabTime" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <el-form-item style="display: none" name="queryType">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">按钮类型</span>
                <el-input v-model="queryType" name="queryType" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <!--          时间-->
          <el-form-item>
            <div class="clear">
              <div class="fl">
                <span class="c_tip">收费时间</span>
                <el-date-picker
                  v-model="data.chargeTimeStart"
                  name="chargeTimeStart"
                  type="date"
                  placeholder="选择日期"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 143px;"
                />
                <span style="padding: 0 1px">至</span>
                <el-date-picker
                  v-model="data.chargeTimeEnd"
                  name="chargeTimeEnd"
                  type="date"
                  placeholder="选择日期"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 143px;"
                />
              </div>
            </div>
          </el-form-item>

          <!--          类型-->
          <el-form-item style="display: none" name="patientType">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">传值</span>
                <el-input v-model="data.patientType" name="patientType" />
              </div>
            </div>
          </el-form-item>
          <el-form-item>
            <div class="clear">
              <div class="fl">
                <span class="c_tip">类型</span>
                <el-checkbox-group v-model="data.patientType" class="c_checkbox">
                  <el-checkbox v-for="(item,index) in patientType" :key="item.value" :label="item.value">{{ item.label }}</el-checkbox>
                </el-checkbox-group>
              </div>
            </div>
          </el-form-item>

          <el-form-item style="display: none" name="statisticalOject">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">传值</span>
                <el-input v-model="data.statisticalOject" name="statisticalOject" />
              </div>
            </div>
          </el-form-item>
          <el-form-item>
            <div class="clear">
              <div class="fl">
                <span class="c_tip">统计对象</span>
                <el-radio-group v-model="data.statisticalOject">
                  <el-radio :label="0">所有病人</el-radio>
                  <el-radio :label="1">药品费用大于零的病人</el-radio>
                  <el-radio :label="2">药品(非中药饮片)费用大于零的病人</el-radio>
                  <el-radio :label="3">药品(非中药颗粒)费用大于零的病人</el-radio>
                  <el-radio :label="4">药品(非中药)费用大于零的病人</el-radio>
                </el-radio-group>
              </div>
            </div>
          </el-form-item>

          <!--          基本药物-->
          <el-form-item style="display: none" name="basedrug">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">传值</span>
                <el-input v-model="data.basedrug" name="basedrug" />
              </div>
            </div>
          </el-form-item>
          <el-form-item>
            <div class="clear">
              <div class="fl">
                <span class="c_tip">基本药物</span>
                <el-checkbox-group v-model="data.basedrug" class="c_checkbox">
                  <el-checkbox v-for="(item,index) in basedrug" :key="item.value" :label="item.value">{{ item.label }}</el-checkbox>
                </el-checkbox-group>
              </div>
            </div>
          </el-form-item>

          <el-form-item>
            <div class="sbtn_box">
              <el-button size="small" type="primary" @click="onSubmit(inventoryUrl,'清单表','1')">清单表</el-button>
              <el-button size="small" type="primary" @click="onSubmit(inventoryByDeptUrl,'按科室统计','2')">按科室统计</el-button>
              <el-button size="small" type="primary" @click="onSubmit(inventoryByGroupUrl,'按医疗组统计','3')">按医疗组统计</el-button>
              <el-button size="small" type="primary" @click="onSubmit(inventoryByDoctorUrl,'按医生统计','4')">按医生统计</el-button>
              <el-button size="small" type="primary" @click="onSubmit(inventoryBybasicUrl,'销售清单','5')">销售清单</el-button>
              <el-button size="small" type="primary" @click="onSubmit(inventoryByAllUrl,'全院统计','6')">全院统计</el-button>
            </div>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      width="95%"
      @close="closeVisible"
    >
      <iframe id="reportFrame14" name="reportFrame2" width="1390" height="980" />
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="closeVisible">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'InventoryCpt',
  mounted() {
    let userInfo = localStorage.getItem("user");
    this.lister = JSON.parse(userInfo).real_name
    this.hospital_code = JSON.parse(userInfo).his_code
    this.medical = JSON.parse(userInfo).his_name
  },
  activated() {
    let userInfo = localStorage.getItem("user");
    this.lister = JSON.parse(userInfo).real_name
    this.hospital_code = JSON.parse(userInfo).his_code
    this.medical = JSON.parse(userInfo).his_name
  },
  data() {
    return {
      dialogTitle: '',
      inventoryUrl: 'http://yuwenbincl.xicp.net:19133/webroot/ReportServer?reportlet=inventory.cpt',
      inventoryByDeptUrl: 'http://yuwenbincl.xicp.net:19133/webroot/ReportServer?reportlet=inventoryByDept.cpt',
      inventoryByGroupUrl: 'http://yuwenbincl.xicp.net:19133/webroot/ReportServer?reportlet=inventoryByGroup.cpt',
      inventoryByDoctorUrl: 'http://yuwenbincl.xicp.net:19133/webroot/ReportServer?reportlet=inventoryByDoctor.cpt',
      inventoryBybasicUrl: 'http://yuwenbincl.xicp.net:19133/webroot/ReportServer?reportlet=inventoryBybasic.cpt',
      inventoryByAllUrl: 'http://yuwenbincl.xicp.net:19133/webroot/ReportServer?reportlet=inventoryByAll.cpt',
      hospital_code: '0', // 医院编码
      medical: 1, // 医疗机构
      lister: '制表人', // 	制表人
      tabTime: new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),	// 制表时间
      queryType: '0', // 	1 按照药品金额排序 2按药品数量排序 3按通用名称金额排序
      data: {
        chargeTimeStart: '', // 	开始收费时间
        chargeTimeEnd: '', // 		结束收费时间
        patientType: [], //	类型
        statisticalOject: [],
        basedrug: []
      },
      patientType: [{
        value: 0,
        label: '门诊'
      }, {
        value: 1,
        label: '急诊'
      }, {
        value: 2,
        label: '出院'
      }, {
        value: 3,
        label: '住院'
      }],
      basedrug: [{
        value: 1,
        label: '国家基药'
      }, {
        value: 2,
        label: '省基药'
      }],
      dialogVisible: false,
      pType: '11',
      sbtnFlag: false
    }
  },
  methods: {
    onSubmit(startUrlValue, dialogTitleName, queryTypeVal) {
      if (this.data.chargeTimeStart > this.data.chargeTimeEnd) {
        this.$message({
          message: '注意！您选择的结束时间小于开始时间，请重新选择',
          type: 'warning'
        })
        this.data.chargeTimeEnd = ''
      } else if (this.data.chargeTimeStart === '' || this.data.chargeTimeEnd === '' ||
        this.data.chargeTimeStart === null || this.data.chargeTimeEnd === null) {
        this.$message({
          message: '请选择时间范围',
          type: 'warning'
        })
      } else {
        this.dialogTitle = dialogTitleName
        this.queryType = queryTypeVal
        this.dialogVisible = true
        this.$nextTick(function() {
          document.paraForm2.action = startUrlValue // 通过 form 的 name 获取表单，并将报表访问路径赋给表单的 action
          document.paraForm2.submit() // 触发表单提交事件
        })
      }
    },
    closeVisible() {
      this.dialogVisible = false
      this.queryInfo = {
        queryType: '', // 	1 按照药品金额排序 2按药品数量排序 3按通用名称金额排序
        chargeTimeStart: '', // 	开始收费时间
        chargeTimeEnd: '', // 		结束收费时间
        patientType: [], //	类型
        statisticalOject: [],
        basedrug: []
      }
    }
  }
}
</script>

<style scoped lang="scss">
  .query{
    width:100%;
    height:100%;
    background:#e6edf5;
    .check{
      font-size:12px;
      line-height:40px;
      background:#fff;
      text-align:center;
      .c_left{
        width:115px;
        float:left;
        line-height:65px;
      }
      .c_right{
        overflow:hidden;
        color:#636365;
        border-left:1px solid #e6edf5;
        padding:15px 0;
        position:relative;
        .show_btn{
          position:absolute;
          right:20px;
          bottom:15px;
          border:1px solid #e1e1e1;
          background:#f9fafc;
          border-radius:2px;
          text-align:center;
          line-height:32px;
          width:70px;
          height:32px;
          font-size:14px;
          color:#9f9f9f;
          cursor: pointer;
        }
        .fl{
          margin-bottom:10px;
          display: flex;
          align-content: center;
          align-items: center;
        }
        .c_tip{
          display:inline-block;
          width:80px;
          padding-right:10px;
          text-align:right;
        }
        .c_input{
          width:131px;
          height:40px;
          border:1px solid #dcdfe6;
          border-radius:4px;
          padding-left:5px;
        }
        .c_input::-webkit-input-placeholder {
          color: #dcdfe6;
        }
        .c_input::-ms-input-placeholder {
          color: #dcdfe6;
        }
        .c_input::-moz-input-placeholder {
          color: #dcdfe6;
        }
        .c_search{
          width:300px;
        }
        .c_searchbtn{
          display:inline-block;
          width:34px;
          height:25px;
          margin-left:3px;
          background:#28a4f4;
          color:#fff;
          font-size:12px;
          text-align:center;
          line-height:26px;
          border-radius:6px;
          cursor:pointer;
        }
        .c_searchbtn_clear{
          display:inline-block;
          width:34px;
          height:25px;
          margin-left:3px;
          background:#F56C6C;
          color:#fff;
          font-size:12px;
          text-align:center;
          line-height:26px;
          border-radius:6px;
          cursor:pointer;
        }
        .c_checkbox{
          width:400px;
          height:40px;
          margin-left: 5px;
          display: flex;
          justify-content: left;
        }
        .btn_clear{
          padding:0;
          width:150px;
          height:40px;
          line-height:40px;
        }
        .sbtn_box{
          text-align:left;
          padding-left:82px;
        }
        .c_select{
          width:130px;
        }
        @media screen and (min-width:1466px){
          .c_select{
            width:150px;
          }
          .btn_clear{
            padding:0;
            width:70px;
            height:40px;
            line-height:40px;
          }
          .c_input{
            width:150px;
          }
          .c_searchbtn{
            width:42px;
            margin-left:4px;
          }
          .c_tip{
            width:100px;
          }
        }
      }
    }
    .list_tip{
      font-size:14px;
      color:#29a4f2;
      padding: 2px;
    }
    .table_box{
      padding:0 18px;
    }
  }
  /deep/.el-checkbox__label{
    width: 100px;
    font-size: 12px;
  }
  /deep/.el-radio__label{
    font-size: 12px;
  }
  /deep/.el-checkbox__label{
    width: 100px;
  }
  /deep/.el-form-item__content{
    font-size: 12px;
  }
  /deep/.el-form-item{
    margin: 0;
  }
</style>
